package eco2automotive.tasks;
import eco2automotive.port.ConnectionControl;
import eco2automotive.gui.components.Panel_TxRx;

public class Thread_app extends Thread{
   private boolean continuar = true; 
   ConnectionControl connControl;
   Panel_TxRx PANEL_TXRX;
   
   public Thread_app(ConnectionControl connControl, Panel_TxRx PANEL_TXRX){
    this.connControl=connControl;
    this.PANEL_TXRX=PANEL_TXRX;
    }
     public void detenElHilo(){continuar=false;}
     public void resumeHilo(){continuar=true;}
   
   public void run()
   {               
       while(continuar){           
    try{this.sleep(1000);}catch(Exception e){} // Actualizo cada 1 seg.          
          String data="";      
          if((this.connControl!=null))              
              if(connControl.DATA_AVAILABLE()){                                 
                    data=connControl.getRXinfo();
                    System.out.println("DATA AVAILABLE?? "+data);                  
                    this.PANEL_TXRX.updateRX_INFO(data);                                                                                
                    this.PANEL_TXRX.updateTX_INFO(connControl.getTXinfo());
                                  }      

                }
        }
   }